package sjtu.rfid.rri.services.casp;

import javax.jws.WebService;

import sjtu.rfid.rri.services.casp.exception.NoSuchNameException;
import sjtu.rfid.rri.services.casp.exception.ProcessException;
import sjtu.rfid.rri.services.casp.model.BizTransType;
import sjtu.rfid.rri.services.casp.model.BoundaryInfo;
import sjtu.rfid.rri.services.casp.model.DataInfo;
import sjtu.rfid.rri.services.casp.model.PatternInfo;

@WebService
public interface CASPService {

	/**
	 * Initialize the process service
	 * 
	 * @param lrName
	 *            the logical reader name
	 * @param boundaryInfo
	 *            the Boundary Information
	 * @param patternInfo
	 *            the Pattern Information
	 * @param processVerify
	 *            whether to verify the process
	 * @return the unique process ID
	 * @throws ProcessException
	 *             if there exists some process error!
	 */
	long init(String lrName, BoundaryInfo boundaryInfo,
			PatternInfo patternInfo, boolean processVerify)
			throws ProcessException;

	/**
	 * Stop the specified process service, it will end the service and do some
	 * cleaning work.
	 * 
	 * @param processUID
	 *            the unique process ID
	 * @throws NoSuchNameException
	 *             if processUID doesn't exist!
	 * @throws ProcessException
	 *             if there exists some process error!
	 */
	void stop(long processUID) throws NoSuchNameException, ProcessException;

	/**
	 * Resume the specified process service
	 * 
	 * @param processUID
	 *            the unique process ID
	 * @throws NoSuchNameException
	 *             if processUID doesn't exist!
	 * @throws ProcessException
	 *             if there exists some process error!
	 */
	void resume(long processUID) throws NoSuchNameException, ProcessException;

	/**
	 * Pause the specified process service
	 * 
	 * @param processUID
	 *            the unique process ID
	 * @throws NoSuchNameException
	 *             if processUID doesn't exist!
	 * @throws ProcessException
	 *             if there exists some process error!
	 */
	void pause(long processUID) throws NoSuchNameException, ProcessException;

	/**
	 * Indicate some operations have been completed.
	 * 
	 * @param processUID
	 *            the unique process ID
	 * @param data
	 *            the completed operation data
	 * @param disposition
	 *            the disposition of the business operation
	 * @param bizTransNumber
	 *            the business transaction number
	 * @param bizTransType
	 *            the business transaction type
	 * @throws NoSuchNameException
	 *             if processUID doesn't exist!
	 * @throws ProcessException
	 *             if there exists some process error!
	 */
	void operationComplete(long processUID, DataInfo data, String disposition,
			int bizTransNumber, BizTransType bizTransType)
			throws NoSuchNameException, ProcessException;

}
